; (function () {
	new Vue({
		el: '#jwk-list',
		data() {
			return {
				isExtenseFlag: false,
				power: JSON.parse(localStorage.getItem('permissions')),
				//滚动条配置
				scrollDisx: 0,
				ops: {
					bar: {
						background: '#000',
						onlyShowBarOnScroll: false,
						keepShow: false,
						hoverStyle: false,
						size: '10px',
						opacity: 0.3
					},
					scrollPanel: {
						scrollingX: true,
						scrollingY: false
					}
				},
				current:1,
				pages: [{name: '10', code: '10'}, {name: '15', code: '15'}, {name: '20', code: '20'}],
				pageCount: ['10'],
				rowIndex:null,
				parkInfo: {},
				keyword: '',
				park_id: [],
				city_code: [],
				district_code: [],
				columns: '',
				orders: '',
				page: 1,
				limit: 10,
				dataList: {
					bizRentOfficeList: []
				},

				acreage: {
					list: [
						{
							name: '<150㎡',
							code: 'A'
						},
						{
							name: '150㎡-300㎡',
							code: 'B'
						},
						{
							name: '300㎡-500㎡',
							code: 'C'
						},
						{
							name: '500㎡-800㎡',
							code: 'D'
						},
						{
							name: '>800㎡',
							code: 'E'
						},
					],
					active: []
				}, //面积
				rent: {
					list: [
						{
							name: '≤2元',
							code: 'A'
						},
						{
							name: '2-3元',
							code: 'B'
						},
						{
							name: '3-5元',
							code: 'C'
						},
						{
							name: '5-7元',
							code: 'D'
						},
						{
							name: '7-9元',
							code: 'E'
						},
						{
							name: '＞9元',
							code: 'F'
						},
					],
					active: []
				},
				parkData: [],//园区下拉列表
				cityData: [],//城市下拉列表
				countyData: [], //区县下拉列表
				setCountyData: [],//筛选过的区县
			}
		},
		filters: {
			timestamp: function (time) {
				return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd HH:mm')
			},
		},
		methods: {
			selectParkId(val) {
				this.parkInfo = val
			},
			// 获取园区数据
			getParkData(val, callback) {
				console.log(val)
				this.parkInfo = {
					name:val,
					id:'#'
				}
				var that = this;
				hlhttp.get({
					url: 'jwk/park_info/_search',
					data: {
						keyword: val || '#'
					},
					success: data => {
						callback(data)
					}
				})
			},
			// 获取园区
			getPark() {
				var that = this;
				hlhttp.get({
					url: 'jwk/park_info/_search',
					data: {
						keyword: '#'
					},
					success: data => {
						data.map(item => {
							item.code = item.id
						})
						that.parkData = data
					}
				})
			},
			//获取区域数据
			getAreaData() {
				var that = this;
				hlhttp.get({
					url: 'configure/dict',
					data: { 'module_code': 'CSTM_JWK', 'config_name': 'CSTM_JWK_REGION_CITY' },
					success: data => {
						data.map(item => {
							item.name = item.dictName
							item.code = item.dictCode
						})
						that.cityData = data;
						that.getCountyData()
					}
				})
			},
			// 获取县区数据
			getCountyData() {
				var that = this;
				hlhttp.get({
					url: 'configure/dict',
					data: { 'module_code': 'CSTM_JWK', 'config_name': 'CSTM_JWK_REGION_DISTRICT' },
					success: data => {
						data.map(item => {
							item.name = item.dictName
							item.code = item.dictCode
						})
						that.countyData = data;
					}
				})
			},
			//选择城市
			selectCityCode(item) {
				this.setCountyData = []
				this.district_code = []
				this.countyData.map(single => {
					if (single.parentDictCode == item[0].code) {
						this.setCountyData.push(single)
					}
				})
			},
			// 获取办公租赁列表
			getData() {
				var that = this;
				hlhttp.get({
					url: 'jwk/biz_rent_office/_search',
					data: {
						"keyword": this.keyword || '#',
						"park_id": this.parkInfo.id ? this.parkInfo.id : '#',
						"park_name": this.parkInfo.name ? this.parkInfo.name : '#',
						"city_code": this.city_code + '' ? this.city_code + '' : '#',
						"district_code": this.district_code + '' ? this.district_code + '' : '#',
						"acreage_flag": this.acreage.active + '' ? this.acreage.active + '' : '#',// 面积标识，从小到大依次A-E
						"rent_price_flag": this.rent.active + '' ? this.rent.active + '' : '#',// 租金标识，从小到大依次A-F
						"columns": this.columns || '#',
						"orders": this.orders || '#',
						"page": this.page,
						"limit": this.limit
					},
					success: data => {
						that.dataList = data
					}
				})
			},
			// 重置
			reset() {
				this.keyword = ''
				this.park_id = []
				this.city_code = []
				this.district_code = []
				this.acreage.active = []
				this.rent.active = []
				this.parkInfo = {}
				this.columns = '#'
				this.orders = '#'
				this.page = 1
				this.limit = 10
				this.getData()
			},
			runkTime(val){
				this.columns = val
				this.orders = this.orders?(this.orders =='DESC'?'ASC':'DESC'):'ASC'
				this.getData()
			},
			// 停用
			disableItem(item) {
				var that = this;
				hlhttp.put({
					url: 'jwk/biz_rent_office/enable_and_disable',
					data: {
						id: item.id,
						is_valid: item.isValid == '0' ? '1' : '0'
					},
					success: data => {
						hl.toast('设置成功')
						that.getData()
					}
				})
			},
			// 删除
			delItem(item) {
				var that = this;
				hlhttp.delete({
					url: 'jwk/biz_rent_office?id=' + item.id,
					data: {
						id: item.id,
					},
					success: data => {
						hl.toast('删除成功')
						that.getData()
					}
				})
			},
			// 翻页
			turnPage (num) {
				this.page = num
				this.getData();
			},
			getDateTime: function (arr) {
        var _this = this;
				this.pageCount = [arr[0].code]
				this.limit = arr[0].code
        setTimeout(function() {
          _this.getData()
        }, 100);
      },


			openSearch() {
				this.isExtenseFlag = !this.isExtenseFlag
			},
			handleComplete(vertical, horizontal) {
				this.scrollDisx = horizontal.process * 100
			},
			toCreateWorkPage() {
				hlUrlUtil.goTo('jwkWrokAddEdit', { ddtab: true }, true)
			},
			toEditWorkPage(id) {
				hlUrlUtil.goTo('jwkWrokAddEdit', { ddtab: true, id: id }, true)
			},
			previewItem(id) {
				hlUrlUtil.goTo('jwkView', { ddtab: true, id: id }, true)
			},
			toCreateRegionPage() {
				hlUrlUtil.goTo('jwkRegionConfig', { ddtab: true, mode: 'create' }, true)
			},
			toCreateMatchingPage() {
				hlUrlUtil.goTo('jwkMatching', { ddtab: true, mode: 'create' }, true)
			},
			toCreateParkPage() {
				hlUrlUtil.goTo('jwkPark', { ddtab: true, mode: 'create' }, true)
			},
			//滚动初始化
			rollInit() {
				const self = this;
				let disx = 0;
				function scrollFunc(e, ref) {
					e = e || window.event;
					if (e && e.preventDefault) {
						if (e.deltaY > 0) {
							disx += 10
						}
						if (e.deltaY < 0) {
							disx -= 10
						}
						if (disx > 100) { disx = 100 }
						if (disx < 0) { disx = 0 }
						self.$refs[ref].scrollTo(
							{
								x: disx + '%'
							},
							10
						);
						e.preventDefault();
						e.stopPropagation();
					} else {
						e.returnvalue = false;
						return false;
					}
				}

				document.querySelector('.hl-scroll-container').onmouseenter = function () {
					disx = self.scrollDisx;
					scrollLeft('.hl-scroll-container', 'scrollWrap')
				}

				document.querySelector('.hl-scroll-container').onmouseleave = function () {
					document.querySelector('.hl-scroll-container').onmousewheel = null;
				};

				function scrollLeft(className, ref) {
					function addEventListFn(e) { scrollFunc(e, ref) }
					document.querySelector(className).onmousewheel = addEventListFn
				}
			}
		},
		mounted() {
			let style = document.createElement('style')
			style.innerHTML = `
				.__vuescroll .__panel{overflow:hidden !important}
			`
			this.$refs.vs.appendChild(style)
			this.rollInit()
			this.getData()
			this.getPark()
			this.getAreaData()
		}
	})
}())